package com.seven.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @Author seven
 * @Date 2020/5/9 15:34
 **/
@Service
public class HelloService {

    //告诉spring这是一个异步方法
    @Async
    public String sayHello(String name){
        //休息线程1秒
        try { TimeUnit.SECONDS.sleep(1);} catch (InterruptedException e) {e.printStackTrace();}
        System.out.println("处理数据~"+name);
        return "你好,"+name;
    }
}
